package com.zx.nacosconsumer.controller;

import com.zx.nacosconsumer.service.FeignClientService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

/**
 * @Description ConsumerController
 * @Author Zhang Xin
 * @Date 2020/7/23
 */
@RestController
public class ConsumerController {
    @Autowired
    FeignClientService feignClientService;

    @GetMapping("/hiSentinel")
    public String hiSentinel(){
        try {
            Thread.sleep(1000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        return feignClientService.hi("Sentinel");
    }

    @Autowired
    RestTemplate restTemplate;

    @GetMapping("/hi-restTemplate")
    public String hiResttemplate(String name){
        return restTemplate.getForObject("http://nacos-provider/hi?name=restTemplate",String.class);

    }


    @GetMapping("/hi-feign")
    public String hiFeign(){
        return feignClientService.hi("feign");
    }

}
